﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;

namespace BBAnalyzer
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string src = "server=" + biztalkDatabase.Text + ";database=" + mgmtDatabase.Text + ";Trusted_Connection=yes";
            using (SqlConnection con = new SqlConnection(src))
            {
                try
                {
                    con.Open();
                    this.Hide();
                    string server = biztalkDatabase.Text;
                    string db = mgmtDatabase.Text;
                    analyzer ana = new analyzer(db, server);
                    ana.DatabaseServer.Content = biztalkDatabase.Text;
                    ana.mgmtDb.Content = mgmtDatabase.Text;
                    ana.ShowDialog();
                    this.Visibility = 0;
                }
                catch (SqlException)
                {
                    MessageBox.Show("Error connection to database, verify that the database connection data is correct.");
                }
            }
        }
        
    }
}
